<?php
/*
Template Name: Tuan
*/
//t(1);
get_header(); $catslug=get_query_var('category_name');
$searchq='';
if(isset($_POST['s']))$searchq=$_POST['s'];
?>


<div class='videoduthi_side'>
                        <div class='side_content'>
                            <img src='<?php echo get_template_directory_uri()?>/img/header_videoduthi.png' class='title' alt=''/>
                            <div id='week_menu_content'>
                                <div id='week_menu'>
                                    <ul >
                                        <li id='week1' class='week_btn'>
                                        	<?php if($catslug=='tuan1'){?>
                                            <img src='<?php echo get_template_directory_uri()?>/img/button_week1_active.png' class='button_week_active' alt=''/>
                                            <?php }else{?>
                                            <a href='<?php echo home_url('/category/tuan1/')?>'><img src='<?php echo get_template_directory_uri()?>/img/button_week1.png' class='button_week' alt=''/></a>
                                            <?php }?>
                                        </li> 
                                        <li id='week2' class='week_btn'>
                                            <?php if($catslug=='tuan2'){?>
                                            <img src='<?php echo get_template_directory_uri()?>/img/button_week2_active.png' class='button_week_active' alt=''/>
                                            <?php }else{?>
                                            <a href='<?php echo home_url('/category/tuan2/')?>'><img src='<?php echo get_template_directory_uri()?>/img/button_week2.png' class='button_week' alt=''/></a>
                                            <?php }?>
                                        </li> 
                                        <li id='week3' class='week_btn'>
                                            <?php if($catslug=='tuan3'){?>
                                            <img src='<?php echo get_template_directory_uri()?>/img/button_week3_active.png' class='button_week_active' alt=''/>
                                            <?php }else{?>
                                            <a href='<?php echo home_url('/category/tuan3/')?>'><img src='<?php echo get_template_directory_uri()?>/img/button_week3.png' class='button_week' alt=''/></a>
                                            <?php }?>
                                        </li> 
                                        <li id='week4' class='week_btn'>
                                            <?php if($catslug=='tuan4'){?>
                                            <img src='<?php echo get_template_directory_uri()?>/img/button_week4_active.png' class='button_week_active' alt=''/>
                                            <?php }else{?>
                                            <a href='<?php echo home_url('/category/tuan4/')?>'><img src='<?php echo get_template_directory_uri()?>/img/button_week4.png' class='button_week' alt=''/></a>
                                            <?php }?>
                                        </li> 
                                        <li>
                                        
                                            <form name='search' action='<?php echo home_url('/') ?>' method='get'>
                                            <span id='search_button'>
                                            
                                                <input id='search_input' name='s' type='text' value='<?php echo $searchq?>' />
                                                <span style='margin-left:-20px'>
                                                    <a href='javascript:;' onclick='document.search.submit();'>
                                                        <img src='<?php echo get_template_directory_uri()?>/img/search.png' atl=''/>
                                                        <img id='search_loading' src='<?php echo get_template_directory_uri()?>/img/loader.gif' alt=''/>
                                                    </a>
                                                </span>
                                            </span>
                                            </form> 
                                        </li>
                                    </ul>    
                                </div>

                            </div>
                            <div class='videoduthi_info'>
                                
<?php 

$cat=get_category_by_slug($catslug);
$args = array(
					 		'showposts'=>-1,
					 		'category__in'=>array($cat->cat_ID),
							'orderby' => 'id',
							'order' => 'DESC',
							
						);						
					$posts= query_posts($args);
					$searchname=sanitize_title($searchq);
					$arrposturl=array();
					$notfound=true;
					if(have_posts()){
?>
						
                                <div id='video_content'>
                                <div id='loading_video' style='background-color:rgba(255,255,255,0.5);width:565px;height:365px;position:absolute;display:none;z-index: 13'>
                                        <img src='<?php echo get_template_directory_uri()?>/img/loader.gif' style='right: -35px;width: 25px !important;top: 175px;position:absolute;left: 250px;' alt=''/>
                                    </div>
                                <?php while ( have_posts() ) :the_post();                          
                                	//if(empty($searchname) || (strpos($post->post_name,$searchname)!==false && strpos($post->post_name,$searchname)>=0)){
                                //$count = get_post_meta($postid,'votecount',1);
                                	$arrposturl[$post->ID]=basename(get_permalink());
                                $notfound=false;
									?>	
		
                                    <a href='<?php the_permalink()?>'>
                                        <div class='video'>
                                        <div class='video_info'>
                                        	<?php the_title()?>
                                        </div>
                                        <?php echo the_post_thumbnail('medium',array('style'=>'','title'=>get_the_title(),'alt'=>get_the_title(),'class'=>'video_thumbnail') );?>
                                           <?php $vote=get_post_meta($post->ID,'vote',1);
                                           $count=0;	
                                           if(!empty($vote))$count=count($vote);
                                           ?>     
                                            
                                            <div class='video_desc'>
                                                <span class='video_name' style="width: 105px;"><?php echo post_custom('songname')?></span>                                                  
                                                <span class='video_img'><img src='<?php echo get_template_directory_uri()?>/img/video_like.png' alt=''/></span>
                                                <span class='video_like_number' id="like<?php echo $post->ID?>" style="margin-top: 4px;margin-right: 5px"><?php echo $count; ?></span>                                            
                                            </div>
                                        </div>
                                    </a>
                                    
                                    
                                    <?php 
                                    endwhile;
                                    ?>
                                    </div>
                                    <?php  
					}else{
                                    	if($catslug=='tuan1'){
                                    		?>
                                    		<div class='vongbanket_detail'>
			                                    <img src='<?php echo get_template_directory_uri()?>/img/tuan1_info.png' alt=''/>
			                                </div>
                                    		<?php 
                                    	}
	                                    if($catslug=='tuan2'){
	                                    	?>
	                                    	<div class='vongbanket_detail'>
			                                    <img src='<?php echo get_template_directory_uri()?>/img/tuan2_info.png' alt=''/>
			                                </div>	
	                                    	<?php }
	                                    if($catslug=='tuan3'){
	                                    		?>
	                                    		<div class='vongbanket_detail'>
				                                    <img src='<?php echo get_template_directory_uri()?>/img/tuan3_info.png' alt=''/>
				                                </div>	
	                                    		<?php
	                                    	}
	                                    if($catslug=='tuan4'){
	                                    		?>
	                                    		<div class='vongbanket_detail'>
				                                    <img src='<?php echo get_template_directory_uri()?>/img/tuan4_info.png' alt=''/>
				                                </div>	
	                                    		<?php
	                                    	}
                                    }
                                    ?>
                                    
                                
                            </div>
                           
                        </div>

                    </div>


	<script>
	
    (function($){
        $(window).load(function(){
            $("#video_content").mCustomScrollbar();
            // $("#video_content").mCustomScrollbar({
            //     horizontalScroll:true,
            //     theme:"light",
            //     scrollButtons:{
            //         enable:true
            //     }
            // });
        });        
        $('#search_input').watermark('Tìm theo tên, bài hát, địa điểm...');
    })(jQuery);    

    
</script>


<?php get_footer(); ?>